package test;

import dao.UserMapper;
import entity.Bill;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.junit.Test;
import utils.MyBatisUtil;

import java.util.ArrayList;
import java.util.List;

public class ShangJi04 {

    private Logger logger=Logger.getLogger(ShangJi01.class);

    @Test
    public void TestGetList(){
        SqlSession sqlSession=null;
        List<Bill> list=new ArrayList<>();
        try {
            sqlSession= MyBatisUtil.createSqlSession();
            Bill bill=new Bill();
            bill.setProviderId(13);
            bill.setProductName("洗");
            bill.setIsPayment(2);
            list=sqlSession.getMapper(UserMapper.class).getListColl(bill);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MyBatisUtil.closeSqlSession(sqlSession);
        }
        for (Bill bill:list){
            logger.debug("商品名称:"+bill.getProductName()+",供应商编码:"+bill.getProvider().getProCode()+",供应商名称:"
                    +bill.getProvider().getProName()+",供应商联系人:"+bill.getProvider().getProContact()+",供应商联系电话:"
                    +bill.getProvider().getProPhone()+",账单金额:"+bill.getTotalPrice()+",是否付款:"+bill.getIsPayment()+",创建时间:"+bill.getCreationDate());
        }
    }
}
